// 登录
function login() {
    let account = $("#name").val();
    let password = $("#password").val();
    if (account == "") {
        return;
    }
    if (password == "") {
        return;
    }
    $.post("Login.do", {account: account, password: password }, function (sdata) {
        console.log(sdata)
        if (sdata == 0) {
            location.href = "iframe.html";
        } else if (sdata == 1) {
            $("#jg").text("账户或者密码不对！")
        } else if (sdata == 2) {
            $("#jg").text("从账户不存在！")
        } else {
            alert("异常！")
        }
    })
}

// 修改密码
function UpDatePWD() {
    //重置表单
    $("#PWD")[0].reset();

    $("#ChangePWDSubmit").on("click", function () {
        let account = $("#accountpwd").val();
        let pwd01 = $("#pwd01").val();
        let pwd02 = $("#pwd02").val();

        if (account != "" && account != null && pwd01 == pwd02 && pwd01 != null && pwd01 != "") {
            $.ajax({
                type: "post",
                url: "ChangePWD.do",
                data: {account: account, password: pwd01},
                success: function (data) {
                    //关闭模态框
                    if (data != -1) {
                        console.log(data)
                    } else {
                        alert("账户不存在！")
                    }
                }
            })
            $("#ChangePWDModal").modal("hide");
        }
    })
    $("#ChangePWDModal").modal("show");
}

// 注册
function Register() {
    $("#RegisterModal").modal("show");
}

function RegisterSubmit() {
    let account = $("[name='account']").val();
    let password = $("[name='password']").val();
    let rname = $("[name='rname']").val();
    let rphone = $("[name='account']").val();

    if (account != "" && account != null &&  password != null && password != "" &&
        rname != "" && rname != null && rphone != "" && rphone != null) {
        $("#Register").submit();
    }
    $("#RegisterModal").modal("hide");
}

function accid() {
    let accid = $("#aid").val();
    alert(accid)
    $.post("/Account.do/Register",{account:accid},function (sdata) {
        if (sdata==-1){
            //重置表单
            $("#Register")[0].reset();
            $("#jgs").prop("hidden",false);
        }
    })
}
function dian(){
    $("#jgs").prop("hidden",true);
}

